package com.example.demo.com.java8.date;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;

/**
 * @author chengfei5
 * @date 2018/8/22
 */
public class TestSimpleDateFormat2 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

        //怎么改造成lambda？
        Callable<LocalDateTime> task = new Callable<LocalDateTime>() {
            @Override
            public LocalDateTime call() throws Exception {
                return LocalDateTime.parse("2018-08-22 10:24:33",dtf);
            }
        };
        //创建一个线程池
        ExecutorService pool = Executors.newFixedThreadPool(10);

        List<Future<LocalDateTime>> results = new ArrayList<>();
        for(int i = 0;i<10;i++){
            results.add(pool.submit(task));
        }
        for(Future<LocalDateTime> future:results){
            System.out.println(future.get());
        }

        pool.shutdown();
    }
}
